package main

import (
	"fmt"
	"os"
	"strconv"
)

func f2c(temp_f float64) float64 {
	return (temp_f - 32) / 1.8
}

func c2f(temp_c float64) float64 {
	return temp_c * 1.8 + 32
}

func usage() {
	fmt.Println("gtempconvert F/C NumberOfTemp")
}

func main() {
	if len(os.Args) != 3 {
		usage()
		os.Exit(1)
	}

	method := os.Args[1]

	temp, terr := strconv.ParseFloat(os.Args[2], 64)
	if terr != nil {
		fmt.Println("Error: ", terr)
		os.Exit(1)
	}

	switch method {
	case "c":
		fmt.Printf("After convert Temperture from Celsius to Fahrenheit is: %.2f°F\n", c2f(temp))
	case "f":
		fmt.Printf("After convert Temperture from Fahrenheit to Celsius is: %.2f°C\n", f2c(temp))
	default:
		usage()
		os.Exit(1)
	}
}